// 配置请求对象
import axios from 'axios'

export const baseUrl = "http://localhost:1314/api";

const axiosInstance = axios.create({
    baseUrl
})

axiosInstance.interceptors.request.use(
    function(config) {
        let token = localStorage.getItem('token')
        console.log(config, 'axios 中间件')
        if (token) {
            config.headers.authorization = token
        }
        return config 
    }
)

// 响应时
axiosInstance.interceptors.request.use(
    res => res.data,
    err => {
        console.log(err, '网络错误~~')
    }
)

export { axiosInstance }